home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: newsstand.cit.cornell.edu!ub!csn!alisa!wjjr
- From: wjjr@alisa.org (John J. Rushford Jr.)
- Subject: Re: E-mail from within a Program
- Sender: news@alisa.org
- Message-ID: <DM2so5.JtG@alisa.org>
- Date: Thu, 1 Feb 1996 02:38:29 GMT
- References: <4eoepe$kov@serveru1.naic.wpafb.af.mil>
- Nntp-Posting-Host: alisa
- Organization: My place on the Front Range
- X-Newsreader: TIN [version 1.2 PL2]
-
- Keith D. Anthony - NAIC/TATA - 513-257-6351 (kda36@naic.wpafb.af.mil) wrote:
-
- : I'm attempting to write code that generates a file, probably
- : in /tmp, e-mails this file to a userid, and does all this for
- : a list of users.
-
- : Have tried as a first attempt:
-
- : char *arg1[7];
-
- : arg1[0] = "mail";
- : arg1[1] = "-s";
- : arg1[2] = "test message";
- : arg1[3] = "userid";
- : arg1[4] = " < " /* have even tried \<*/
- : arg1[5] = "/tmp/filename";
- : arg1[6] = NULL;
-
- : (sending to myself) I get a blank message and another one
- : apparently going to "< userid".
-
- : Do I need to manipulated some file descriptors?
- : Anyone done something like this? Can anyone offer some code
- : to e-mail files under program control (yes, in C).
-
- : Oh yes, this is the generic C compiler under SUNOS 4.1.3.
-
- : Thanks, and please e-mail any suggestions. I happily summarize
- : and repost.
-
- The '<' is a meta character recognized by the 'bourne shell'. You'd need to
- modify your execl() to do something like:
-
- execl ("/bin/sh", "sh", "-c", "mailx", "-s", "test message", "userid",
- "<", "/tmp/filename", (char *)NULL);
-
- This should work.
-
- John Rushford
- wjjr@alisa.org
-